<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<jsp:include page="frame/header.jsp"></jsp:include>

<title>论坛主题管理</title>
<style>
.checkbox{
	padding-left: 0px;
}
</style>
</head>

<body>

	<div class="container-fluid">
		<div id="market" class="row-fluid">
			<div>
				<ul class="breadcrumb">
					<li><a href="#">娱乐交友</a> <span class="divider">/</span></li>
					<li><a href="#">树洞论坛</a></li>
				</ul>
			</div>

			<div class="box">
				<div class="box-header well" data-original-title>
					<h2>
						<i class="icon-th"></i> 论坛主题管理
					</h2>

					<div class="box-icon">
						<a href="#" class="btn btn-setting btn-round"><i
							class="icon-cog"></i></a> <a href="#"
							class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
						<a href="#" class="btn btn-close btn-round"><i
							class="icon-remove"></i></a>
					</div>
				</div>
				<div class="box-content">
					<div id="search-form">
						<form class="form-search span6">
							<input type="text" id="searchText"
								class="input-xlarge search-query">
							<button type="button" id="searchBtn" class="btn btn-primary">&nbsp;&nbsp;搜索&nbsp;&nbsp;</button>
							<button type="button" id="searchBtn" class="btn">高级搜索</button>
						</form>
					</div>
					<table id="userInfo" class="table table-striped table-bordered ">
						<thead>
							<tr>
								<th><input type="checkbox"></th>
								<th>标题</th>
								<th>版块</th>
								<th>作者</th>
								<th>回复</th>
								<th>浏览</th>
								<th>最后发表</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td><input type="checkbox"></td>
								<td><a href="">曾经擦肩而过如今相伴相守</a></td>
								<td>灌水专区</td>
								<td>惜之淡沫</td>
								<td>19</td>
								<td>100</td>
								<td>2013-11-27 08:48</td>
							</tr>
							<tr>
								<td><input type="checkbox"></td>
								<td><a href="">晴扉</a></td>
								<td>灌水专区</td>
								<td>白色渴望</td>
								<td>12</td>
								<td>26</td>
								<td>2013-11-24 09:48</td>
							</tr>
							<tr>
								<td><input type="checkbox"></td>
								<td><a href="">中午有点瞌睡，灌灌水听听歌醒瞌睡~</a></td>
								<td>灌水专区</td>
								<td>_殊小沐</td>
								<td>24</td>
								<td>55</td>
								<td>2013-11-27 08:48</td>
							</tr>
						</tbody>
					</table>
					<div id="mypager" class="mypager"></div>

					<div>
						<form id="myform" class="form-horizontal">
							<fieldset>
								<legend>批量操作</legend>
								<table id="" class="table table-striped ">
									<thead>
										<tr>
											<th></th>
											<th>操作</th>
											<th>选项</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios1" id="optionsRadios1"
													value="option1" checked>
											</label></td>
											<td>批量移动到版块</td>
											<td>
											 <select data-placeholder="Your Favorite Football Team" id="selectError2" data-rel="chosen">
										<option value=""></option>
										<optgroup label="娱乐八卦">
										  <optgroup label="我的大学">
										  	<option>青春文学</option>
										  </optgroup>
										  <optgroup label="新闻八卦">
										  	<option>Grand Child</option>
										  	<option>Grand Child</option>
										  </optgroup>
										</optgroup>
										<optgroup label="学习讨论">
										  <option>考研</option>
										  <option>考公务员</option>
										</optgroup>
										
								  </select>
											</td>
										</tr>
										<tr>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios1" id="optionsRadios1"
													value="option1" checked></td>
											<td>批量置顶</td>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios2" id="optionsRadios1"
													value="option1" checked> 解除
											</label> <label class="radio inline"> <input type="radio"
													name="optionsRadios2" id="optionsRadios2" value="option2">
													置顶
											</label></td>
										</tr>
										<tr>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios1" id="optionsRadios1"
													value="option1" checked></td>
											<td>批量打开关闭</td>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios" id="optionsRadios1"
													value="option1" checked> 打开
											</label> <label class="radio inline"> <input type="radio"
													name="optionsRadios" id="optionsRadios2" value="option2">
													关闭
											</label></td>
										</tr>
										<tr>
											<td><label class="radio inline"> <input
													type="radio" name="optionsRadios1" id="optionsRadios1"
													value="option1" checked></td>
											<td>批量删除</td>
											<td>
											<label class="checkbox"><input
													type="checkbox" name="ck" id="sss"
													value="" checked> 删帖不减用户发帖数和积分
											</label></td>
										</tr>
									</tbody>
								</table>
								<div class="form-actions">
									<button id="saveBtn" type="button" class="btn btn-primary">提交</button>									
								</div>
							</fieldset>
						</form>
					</div>
				</div>
			</div>
		</div>
		<!--/fluid-row-->

	</div>
	<!--/.fluid-container-->

	<jsp:include page="frame/scripts.jsp"></jsp:include>
	<script type="text/javascript">
	
	var userInfo = Tempo.prepare("userInfo");//用户信息
	var curPage = 1;//当前页
	var search = '';//搜索串
	
	$(document).ready(function(){
		
		//加载信息列表
		loadPages(curPage);
		
		$("#newBtn").click(function(){
			//跳转至新增页面
			window.location.href = '<c:url value="/admin/addBall" />';
		})
		
	})
	
	function loadPages(currentPage){
		$.ajax({
			url:'users/pagelist',
			dataType:'json',
			data:{pageNum:currentPage,search:$("#searchText").val()},
			success:function(data){
				curPage = data.pageNum;
				userInfo.render(data.result);
				if(data.totalPage <= 1){
					$("#mypager").hide();
				}else{
					$("#mypager").show();
				}
				$('#mypager').bootstrapPaginator({
					currentPage:data.pageNum,
					totalPages:data.totalPage,
					numberOfPages:data.numPerPage,
					onPageChanged:function(event,oldPage,newPage){
						loadPages(newPage);
					}
				});
			}
		})
	}
	
	function del(id){
		if(confirm("Are you sure you want to destroy it?")){
			$.ajax({
				url:'<c:url value="/admin/user/del/'+id+'" />',
				dataType:'json',
				data:{pageNum:curPage},
				success:function(data){
					userInfo.render(data.result);
					refreshPages(data);
				}
			})
		}
	}
	
	function refreshPages(data){
		if(data.totalPage == 1){
			$("#mypager").hide();
		}
		$('#mypager').bootstrapPaginator({
			currentPage:data.pageNum,
			totalPages:data.totalPage,
			numberOfPages:data.numPerPage
		});
	}
	</script>
</body>
</html>
